﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XNA_TD.Menue
{
    public abstract class Knopf : GUI
    {
        private Texture2D texture;
        private Texture2D textureHover = null;

        public Knopf(string name, int width, int height)
        {
            texture = Content.Load<Texture2D>(name);
            try
            {
                textureHover = Content.Load<Texture2D>(name + "Hover");
            }
            catch (Exception e) { }
            size = new Rectangle(
                0,
                0,
                width,
                height);

        }

        public override void Draw()
        {
            var depthStencilState = graphics.GraphicsDevice.DepthStencilState;
            spriteBatch.Begin();
            if (mouseInside && textureHover != null)
            {
                spriteBatch.Draw(textureHover, size, Color.White);
            }
            else
            {
                spriteBatch.Draw(texture, size, Color.White);
            }
            spriteBatch.End();
            graphics.GraphicsDevice.DepthStencilState = depthStencilState;
        }

        public override void Resize()
        {
        }

        public void setPosition(int x, int y)
        {
            size.X = x;
            size.Y = y;
        }

        public void setPositionX(int x)
        {
            size.X = x;
        }

        public void setPositionY(int y)
        {
            size.Y = y;
        }

        public abstract override void MouseClick();
    }
}
